package com.woniu.service;

import com.woniu.entity.Users;
import com.woniu.mapper.UsersMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.DecimalFormat;
import java.util.List;

/**
 * @author 杨光 微信号:tolryg
 * @time 11:38
 */
@Service
public class UsersService {

    @Autowired
    private UsersMapper usersMapper;

    public boolean findUser(String userCode, String userPassword) {

        boolean result = false;

        //查询所有用户
        List<Users> list = usersMapper.selectAll();
        for (Users users : list) {
            String usercode = users.getUserCode();
            String userpassword = users.getUserPassword();
            //如果用户名 和 密码都相等，说明登录成功
            if (usercode.equals(userCode) && userpassword.equals(userPassword)) {
                result=true;
            }
        }

        return result;
    }


    public static void main(String[] args) {
        DecimalFormat df = new DecimalFormat("#00");
            String formattedNum = df.format(50.00);
        System.out.println(formattedNum);
    }
}
